26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
51 #pragma package(smart_init)
64 Graphics::TBitmap* SmallGraphicPtrVal) : SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
66 for(
int x = 0; x < 4; x++)
77 else if(SpeedTagVal == 77)
81 else if(SpeedTagVal == 78)
85 else if(SpeedTagVal == 79)
89 else if(SpeedTagVal == 96)
93 else if(SpeedTagVal == 129)
97 else if(SpeedTagVal == 130)
101 else if(SpeedTagVal == 131)
105 else if(SpeedTagVal == 145)
109 else if(SpeedTagVal == 146)
118 FixedNamedLocationElement(false)
120 for(
int x = 0; x < 4; x++)
131 AnsiString(VLocInput));
144 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
158 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
174 Graphics::TBitmap *GraphicOutput = GraphicPtr;
176 if(LocationName ==
"")
221 GraphicOutput = GraphicPtr;
225 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
227 if((TrackType ==
Simple) && Failed)
239 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
240 AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit01) +
"," + AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit23) +
",EndTrkEl,";
249 Attribute(0), CallingOnSet(false), Length01(
Utilities->DefaultTrackLength), Length23(-1), SpeedLimit01(
Utilities->DefaultTrackSpeedLimit), SpeedLimit23(-1),
250 TrainIDOnElement(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit01(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit23(-1), StationEntryStopLinkPos1(-1), StationEntryStopLinkPos2(-1),
251 SigAspect(FourAspect)
254 for(
int x = 0; x < 4; x++)
270 if(lower.second < higher.second)
274 else if(lower.second > higher.second)
278 else if(lower.second == higher.second)
280 if(lower.first < higher.first)
293 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
294 CheckCount(9), IsARoute(false), AutoSignals(false), PrefDirRoute(false)
298 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
309 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
337 {2, 4}, {6, 2}, {8, 6}, {4, 8},
338 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
348 else if(
Link[2] == -1)
361 else if(
Link[2] == -1)
370 for(
int x = 0; x < 16; x++)
372 if(((Entry == EXArray[x][0]) && (Exit == EXArray[x][1])) || ((Entry == EXArray[x][1]) && (Exit == EXArray[x][0])))
548 throw Exception(
"Error in EntryExitNumber 4");
643 throw Exception(
"Error in EntryExitNumber 5");
737 throw Exception(
"Error in EntryExitNumber 6");
824 throw Exception(
"Error in EntryExitNumber 10");
913 throw Exception(
"Error in EntryExitNumber 11");
1009 throw Exception(
"Error in EntryExitNumber 7");
1040 throw Exception(
"Error in EntryExitNumber 8");
1051 if((ELink > 0) && (ELink < 10) && (ELink != 5))
1053 if(!AutoSigsFlag && !PrefDirRoute)
1057 else if(!AutoSigsFlag && PrefDirRoute)
1068 throw Exception(
"Error in EntryExitNumber 9");
1165 AnsiString NL =
'\n';
1167 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable, perhaps because of failed points; " + NL + NL +
1168 "reachable but too far ahead or with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
1169 "blocked by a train, another route or a changing level crossing; " + NL + NL +
1170 "or invalid - possibly due to a preferred direction mismatch, or a missed signal in a blue route or green route restricted to consecutive signals.";
1177 int InternalLinkCheckArray[9][2] =
1178 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
1183 for(
int x = 0; x < 9; x++)
1185 for(
int y = 0; y < 2; y++)
1192 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
1194 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
1195 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
1196 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
1197 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27
1198 << 60 << 61 << 62 << 63 << 68 << 69 << 70 << 71 << 80 << 81 << 82 << 83 << 125 << 126 << 127 << 128;
1204 int HVArray[10][2] =
1205 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
1207 for(
int x = 0; x < 10; x++)
1209 for(
int y = 0; y < 2; y++)
1218 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1221 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1222 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1224 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
1225 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
1227 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1228 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1231 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1234 for(
int x = 0; x < 40; x++)
1240 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1243 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1244 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1246 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1247 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1249 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1250 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1253 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1256 for(
int x = 0; x < 40; x++)
1262 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1265 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
1266 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1268 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1269 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1271 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1272 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1275 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1278 for(
int x = 0; x < 40; x++)
1304 for(
int x = 0; x < 40; x++)
1310 {{68, 0,
RailGraphics->
FSig68}, {69, 0,
RailGraphics->
FSig69}, {70, 0,
RailGraphics->
FSig70}, {71, 0,
RailGraphics->
FSig71}, {72, 0,
RailGraphics->
FSig72},
1313 for(
int x = 0; x < 8; x++)
1319 {{68, 0,
RailGraphics->
FGSig68}, {69, 0,
RailGraphics->
FGSig69}, {70, 0,
RailGraphics->
FGSig70}, {71, 0,
RailGraphics->
FGSig71}, {72, 0,
RailGraphics->
FGSig72},
1322 for(
int x = 0; x < 8; x++)
1349 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1350 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1351 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1352 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1353 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1354 {0, 0, 129}, {0, -1, 145},
1357 for(
int x = 0; x < 25; x++)
1359 for(
int y = 0; y < 3; y++)
1367 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1368 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1369 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1370 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1371 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1372 {0, 0, 129}, {0, 1, 145},
1375 for(
int x = 0; x < 25; x++)
1377 for(
int y = 0; y < 3; y++)
1385 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1386 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1387 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1388 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1389 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1390 {0, 0, 130}, {-1, 0, 146},
1393 for(
int x = 0; x < 25; x++)
1395 for(
int y = 0; y < 3; y++)
1403 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1404 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1405 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1406 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1407 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1408 {0, 0, 130}, {1, 0, 146},
1411 for(
int x = 0; x < 25; x++)
1413 for(
int y = 0; y < 3; y++)
1421 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1422 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1423 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1424 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1425 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1426 {0, -1, 129}, {1, 0, 130},
1427 {-1, 0, 130}, {0, 1, 145},
1428 {0, -1, 145}, {1, 0, 146},
1431 for(
int x = 0; x < 28; x++)
1433 for(
int y = 0; y < 3; y++)
1451 for(
int x = 0; x < 8; x++)
1453 for(
int y = 0; y < 3; y++)
1471 for(
int x = 0; x < 8; x++)
1473 for(
int y = 0; y < 3; y++)
1491 for(
int x = 0; x < 8; x++)
1493 for(
int y = 0; y < 3; y++)
1511 for(
int x = 0; x < 8; x++)
1513 for(
int y = 0; y < 3; y++)
1521 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1523 for(
int x = 0; x < 4; x++)
1525 for(
int y = 0; y < 3; y++)
1533 0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1534 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1535 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1536 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1542 0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1543 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1544 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1545 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1551 0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1552 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1553 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1554 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1560 0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1561 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1562 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1563 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1585 delete UGMIt->second;
1661 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1662 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1664 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1671 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1672 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1685 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1686 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1688 {4, 6, 2, 8}, {1, 9, 3, 7},
1690 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1692 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8}, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1695 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1696 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6}, {3, 7, 4, 6},
1697 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1698 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1},
1699 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1700 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1701 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1703 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1704 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1705 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1706 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1707 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1708 {4, 6, -1, -1}, {2, 8, -1, -1},
1710 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1712 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1714 {4, 6, -1, -1}, {2, 8, -1, -1},
1719 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1720 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1721 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1722 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1725 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1726 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1727 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1729 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1730 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1731 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1733 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1735 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1736 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1737 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1738 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1739 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1740 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1741 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1742 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1743 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1744 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1745 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1746 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1747 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1749 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1750 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1751 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1752 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1753 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1754 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1755 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1756 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1760 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1761 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1762 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1768 for(
int x = 0; x < 17; x++)
1770 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1772 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1776 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1782 ExistingGraphicLoaded(false), Width(16), Height(16)
1794 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1832 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1836 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1840 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1844 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1867 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1870 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1874 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1878 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1912 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1933 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1947 bool TrackPresent =
false;
1961 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1965 TrackPresent =
true;
1970 return(!TrackPresent);
1978 bool TrackPresent =
false;
1987 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1991 TrackPresent =
true;
1997 return(!TrackPresent);
2002 void TTrack::EraseTrackElement(
int Caller,
int HLocInput,
int VLocInput,
int &ErasedTrackVectorPosition,
bool &TrackEraseSuccessfulFlag,
bool InternalChecks)
2005 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2006 TrackEraseSuccessfulFlag =
false;
2011 ErasedTrackVectorPosition = -1;
2012 AnsiString SName =
"", ErrorString;
2014 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
2020 TrackMapKeyPair.first = HLocInput;
2021 TrackMapKeyPair.second = VLocInput;
2022 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
2033 if(ErrorString !=
"")
2035 throw Exception(ErrorString +
" for EraseTrackElement 1");
2059 ErasedTrackVectorPosition = VecPos;
2060 TrackEraseSuccessfulFlag =
true;
2066 unsigned int VecPos;
2067 InactiveTrackMapKeyPair.first = HLocInput;
2068 InactiveTrackMapKeyPair.second = VLocInput;
2073 VecPos = InactiveTrack2MultiMapIterator->second;
2078 if(ErrorString !=
"")
2080 throw Exception(ErrorString +
" for EraseTrackElement 2A");
2090 TrackEraseSuccessfulFlag =
true;
2111 VecPos = InactiveTrack2MultiMapIterator->second;
2116 if(ErrorString !=
"")
2118 throw Exception(ErrorString +
" for EraseTrackElement 2B");
2142 if(TrackEraseSuccessfulFlag)
2164 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2165 bool PlatAllowedFlag =
false;
2167 TrackLinkingRequiredFlag =
false;
2179 LocationNameEntry.first =
"";
2187 TempTrackElement.
HLoc = HLocInput;
2188 TempTrackElement.
VLoc = VLocInput;
2214 else if(Aspect == 1)
2218 else if(Aspect == 2)
2222 else if(Aspect == 3)
2231 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2234 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2236 if(InactiveFoundFlag)
2240 NonStationOrLevelCrossingPresent =
true;
2244 NonStationOrLevelCrossingPresent =
true;
2248 PlatformPresent =
true;
2259 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2267 PlatAllowedFlag =
true;
2271 PlatAllowedFlag =
true;
2275 PlatAllowedFlag =
true;
2279 PlatAllowedFlag =
true;
2283 TrackLinkingRequiredFlag =
true;
2311 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1048, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2312 (!FoundFlag && !InactiveFoundFlag))
2315 TrackLinkingRequiredFlag =
true;
2347 TrackLinkingRequiredFlag =
true;
2359 else if(FoundFlag || InactiveFoundFlag)
2378 bool BothPointFillets =
true;
2393 TrackLinkingRequiredFlag =
true;
2407 bool InternalChecks)
2411 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2412 bool PlatAllowedFlag =
false;
2414 TrackLinkingRequiredFlag =
false;
2417 LocationNameEntry.first =
"";
2423 TempTrackElement.
HLoc = HLocInput;
2424 TempTrackElement.
VLoc = VLocInput;
2425 for(
int x = 0; x < 4; x++)
2431 TempTrackElement.
Conn[x] = -1;
2435 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2446 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2448 if(InactiveFoundFlag)
2452 NonStationOrLevelCrossingPresent =
true;
2456 NonStationOrLevelCrossingPresent =
true;
2460 PlatformPresent =
true;
2471 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2479 PlatAllowedFlag =
true;
2483 PlatAllowedFlag =
true;
2487 PlatAllowedFlag =
true;
2491 PlatAllowedFlag =
true;
2495 TrackLinkingRequiredFlag =
true;
2526 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1055, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2527 (!FoundFlag && !InactiveFoundFlag))
2530 TrackLinkingRequiredFlag =
true;
2565 TrackLinkingRequiredFlag =
true;
2577 else if(FoundFlag || InactiveFoundFlag)
2596 bool BothPointFillets =
true;
2611 TrackLinkingRequiredFlag =
true;
2641 ShowMessage(
"Gaps must be set before track can be validated");
2651 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2662 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2679 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2686 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2710 std::pair<AnsiString, char>TempMapPair;
2718 TempMapPair.second =
'x';
2728 AnsiString Name =
"";
2729 typedef std::list<AnsiString> TNoPlatsList;
2730 TNoPlatsList::iterator NPLIt;
2731 TNoPlatsList NoPlatsList;
2732 typedef std::list<AnsiString> TLocNameList;
2733 TLocNameList LocNameList;
2738 LocNameList.push_back(LNMMIt->first);
2741 LocNameList.unique();
2742 for(TLocNameList::iterator LNLIt = LocNameList.begin(); LNLIt != LocNameList.end(); LNLIt++)
2746 if(MMRange.first == MMRange.second)
2752 if((LNMMIt->second) < 0)
2766 TempIt = MMRange.second;
2767 if(LNMMIt == --TempIt)
2769 NoPlatsList.push_back(Name);
2773 if(!NoPlatsList.empty())
2775 AnsiString NoPlatsAnsiList =
"";
2776 for(NPLIt = NoPlatsList.begin(); NPLIt != NoPlatsList.end(); NPLIt++)
2778 NoPlatsAnsiList += *NPLIt +
'\n';
2782 if(NoPlatsList.size() > 1)
2784 ShowMessage(
"Please note: the following locations have no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2788 ShowMessage(
"Please note: the following location has no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2803 int NewHLoc, NewVLoc;
2804 bool ConnectionFoundFlag, LinkFoundFlag;
2806 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2808 for(
unsigned int y = 0; y < 4; y++)
2826 ConnectionFoundFlag =
false;
2827 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2833 ConnectionFoundFlag =
true;
2835 LinkFoundFlag =
false;
2836 for(
unsigned int a = 0; a < 4; a++)
2840 LinkFoundFlag =
true;
2856 if(!ConnectionFoundFlag)
2931 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2948 bool UnsetGaps =
false;
2955 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2959 for(
unsigned int y = 0; y < 4; y++)
2971 for(
unsigned int y = 0; y < 4; y++)
2981 for(
unsigned int y = 1; y < 4; y++)
2990 for(
unsigned int y = 0; y < 4; y++)
3003 for(
unsigned int y = 0; y < 4; y++)
3031 int NumberOfActiveElements = 0;
3033 GraphicsFollow =
false;
3037 if(MarkerString[MarkerString.Length()] ==
'1')
3039 GraphicsFollow =
true;
3041 for(
int x = 0; x < NumberOfActiveElements; x++)
3047 TrackElement.
HLoc = TempInt;
3049 TrackElement.
VLoc = TempInt;
3055 TrackElement.
Conn[0] = TempInt;
3079 if((TempInt != -1) && (TempInt < 10))
3089 if((TempInt != -1) && (TempInt < 10))
3106 if(Marker[1] ==
'3')
3110 else if(Marker[1] ==
'2')
3114 else if(Marker[1] ==
'G')
3128 int NumberOfInactiveElements = 0;
3132 for(
int x = 0; x < NumberOfInactiveElements; x++)
3138 TrackElement.
HLoc = TempInt;
3140 TrackElement.
VLoc = TempInt;
3146 bool LocError =
false;
3175 for(
int x = 0; x < NumberOfGraphics; x++)
3186 bool FileError =
false;
3188 for(
int x = 0; x < NumberOfGraphics; x++)
3201 UGME.second =
new TPicture;
3202 UGME.second->LoadFromFile(
UGME.first);
3205 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
3212 catch(
const EInvalidGraphic &e)
3221 delete UGMIt->second;
3226 catch(
const Exception &e)
3235 delete UGMIt->second;
3243 bool FoundInMap =
false;
3262 UGME.second =
new TPicture;
3263 UGME.second->LoadFromFile(
UGME.first);
3266 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
3273 catch(
const EInvalidGraphic &e)
3282 delete UGMIt->second;
3287 catch(
const Exception &e)
3296 delete UGMIt->second;
3321 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
3325 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
3327 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
3330 VecFile << x <<
'\n';
3331 VecFile << TrackElement.
SpeedTag <<
'\n';
3332 VecFile << TrackElement.
HLoc <<
'\n';
3333 VecFile << TrackElement.
VLoc <<
'\n';
3337 VecFile << TrackElement.
Conn[0] <<
'\n';
3341 VecFile << TrackElement.
Attribute <<
'\n';
3347 VecFile << int(1) <<
'\n';
3351 VecFile << int(0) <<
'\n';
3354 VecFile << TrackElement.
Length01 <<
'\n';
3355 VecFile << TrackElement.
Length23 <<
'\n';
3358 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3365 VecFile <<
"3*****" <<
'\0' <<
'\n';
3369 VecFile <<
"2*****" <<
'\0' <<
'\n';
3373 VecFile <<
"G*****" <<
'\0' <<
'\n';
3377 VecFile <<
"4*****" <<
'\0' <<
'\n';
3382 VecFile <<
"******" <<
'\0' <<
'\n';
3387 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
3391 VecFile << x <<
'\n';
3392 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
3393 VecFile << InactiveTrackElement.
HLoc <<
'\n';
3394 VecFile << InactiveTrackElement.
VLoc <<
'\n';
3395 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3396 VecFile <<
"******" <<
'\0' <<
'\n';
3411 GraphicsFollow =
false;
3413 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
3419 AnsiString MarkerString;
3426 if(MarkerString[MarkerString.Length()] ==
'1')
3428 GraphicsFollow =
true;
3430 for(
int x = 0; x < NumberOfActiveElements; x++)
3438 int SpeedTag = TempInt;
3445 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3451 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3456 if((SpeedTag > 87) && (SpeedTag < 96))
3459 if((TempInt < -1) || (TempInt > 3))
3465 if((TempInt < -1) || (TempInt > 999999))
3471 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3472 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3475 if((TempInt < -1) || (TempInt > 5))
3481 if((SpeedTag >= 68) && (SpeedTag <= 75))
3484 if((TempInt != 0) && (TempInt != 1))
3491 if((TempInt < -1) || (TempInt > 999999))
3497 if((TempInt < -1) || (TempInt > 999999))
3503 if((TempInt < -1) || (TempInt > 999999))
3509 if((TempInt < -1) || (TempInt > 999999))
3530 int NumberOfInactiveElements = 0;
3533 if(NumberOfInactiveElements < 0)
3543 for(
int x = 0; x < NumberOfInactiveElements; x++)
3557 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3563 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3590 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3596 AnsiString FileName =
"", TempStr =
"";
3598 for(
int x = 0; x < NumberOfGraphics; x++)
3600 TPicture *TempPicture =
new TPicture;
3609 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3622 catch(
const EInvalidGraphic &e)
3627 for(
int y = x + 1; y < NumberOfGraphics; y++)
3633 ShowMessage(FileName +
3634 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3639 catch(
const Exception &e)
3644 for(
int y = x + 1; y < NumberOfGraphics; y++)
3650 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3651 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3669 for(
int x = 0; x < VecSize; x++)
3692 for(
int x = 0; x < VecSize; x++)
3714 for(
int x = 0; x < VecSize; x++)
3768 for(
int x = 0; x < VecSize; x++)
3826 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3848 if(BothPointFilletsAndBasicLCs)
3923 Bitmap->Canvas->CopyMode = cmSrcCopy;
3925 Graphics::TBitmap *GraphicOutput;
4100 for(
int x = 0; x < 40; x++)
4129 Graphics::TBitmap *GraphicPtr;
4144 Graphics::TBitmap* SignalPlatformGraphic;
4177 if(OldTransparentColour !=
clB5G5R5)
4200 Bitmap->Canvas->CopyMode = cmSrcCopy;
4228 Bitmap->Canvas->CopyMode = cmSrcCopy;
4230 Graphics::TBitmap *GraphicOutput;
4240 if(BaseElement == 1)
4336 for(
int x = 0; x < 40; x++)
4365 Graphics::TBitmap *GraphicPtr;
4380 Graphics::TBitmap* SignalPlatformGraphic;
4443 for(
int x = 0; x < 40; x++)
4451 Graphics::TBitmap* SignalPlatformGraphic;
4492 if(OldTransparentColour !=
clB5G5R5)
4506 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4578 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4592 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4618 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4643 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4673 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4707 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4744 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4761 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4782 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4814 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4821 throw Exception(
"Error - Map & Vector different sizes");
4823 unsigned int NonZeroCount = 0;
4825 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4834 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4840 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4844 TrackMapEntry.first = TrackMapKeyPair;
4845 TrackMapEntry.second = x;
4846 if(!(
TrackMap.insert(TrackMapEntry).second))
4848 throw Exception(
"Error - map insertion failure, TrackVector in error");
4852 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4854 for(
unsigned int y = 0; y < 4; y++)
4879 THVPair GapMapKeyPair, GapMapValuePair;
4882 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4888 GapMapEntry.first = GapMapKeyPair;
4891 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
4895 GapMapEntry.second = GapMapValuePair;
4898 GapMap.insert(GapMapEntry);
4913 bool TrackElementPositionsOK =
true;
4915 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4927 "Footbridge or underpass connection error. Each end must connect to a platform, concourse "
4928 "or other footbridge or underpass, and they can't connect to each other (i.e. a footbridge "
4929 "can't connect to an underpass or vice versa)");
4937 for(
unsigned int y = 0; y < 4; y++)
4955 bool ConnectionFoundFlag;
4959 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
4965 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4974 if(ConnectionFoundFlag)
4979 bool ExitSignal =
false;
4990 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
4992 TrackElementPositionsOK =
false;
4997 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
4999 TrackElementPositionsOK =
false;
5004 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
5008 TrackElementPositionsOK =
false;
5013 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
5016 TrackElementPositionsOK =
false;
5028 ShowMessage(
"Bridge next to a signal - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
5031 TrackElementPositionsOK =
false;
5036 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
5037 TrackElementPositionsOK =
false;
5040 if(!TrackElementPositionsOK)
5047 throw Exception(
"Error in track element positions in FinalCall");
5060 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5066 for(
unsigned int y = 0; y < 4; y++)
5088 bool ConnectionFoundFlag;
5089 bool LinkMatchFound =
false;
5092 if(ConnectionFoundFlag)
5094 for(
unsigned int a = 0; a < 4; a++)
5103 LinkMatchFound =
true;
5114 throw Exception(
"Error in final track linkage - - no matching link found");
5127 throw Exception(
"Error in final track linkage - connection not found");
5142 bool ConnErrorFlag =
false;
5144 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5148 ConnErrorFlag =
true;
5152 ConnErrorFlag =
true;
5156 ConnErrorFlag =
true;
5160 ConnErrorFlag =
true;
5168 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5177 throw Exception(
"ConnError in LinkTrack - Final");
5181 throw Exception(
"ConnError in LinkTrack - Precheck");
5184 bool CLkErrorFlag =
false;
5186 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5190 CLkErrorFlag =
true;
5194 CLkErrorFlag =
true;
5198 CLkErrorFlag =
true;
5202 CLkErrorFlag =
true;
5210 throw Exception(
"CLkError in LinkTrack - Final");
5214 throw Exception(
"CLkError in LinkTrack - Precheck");
5219 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5249 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5265 for(
unsigned int y = 0; y < 4; y++)
5284 bool ConnectionFoundFlag;
5290 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
5299 if(ConnectionFoundFlag)
5302 bool LinkFoundFlag =
false;
5359 for(
unsigned int a = 0; a < 4; a++)
5368 LinkFoundFlag =
true;
5376 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
5386 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
5399 bool ConnErrorFlag =
false;
5401 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5405 ConnErrorFlag =
true;
5409 ConnErrorFlag =
true;
5413 ConnErrorFlag =
true;
5417 ConnErrorFlag =
true;
5425 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5434 throw Exception(
"ConnError in LinkTrack - Final");
5438 throw Exception(
"ConnError in LinkTrack - Precheck");
5441 bool CLkErrorFlag =
false;
5443 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5447 CLkErrorFlag =
true;
5451 CLkErrorFlag =
true;
5455 CLkErrorFlag =
true;
5459 CLkErrorFlag =
true;
5467 throw Exception(
"CLkError in LinkTrack - Final");
5471 throw Exception(
"CLkError in LinkTrack - Precheck");
5475 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5504 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5520 for(
unsigned int y = 0; y < 4; y++)
5539 bool ConnectionFoundFlag =
false;
5541 if(ConnectionFoundFlag)
5545 bool LinkFoundFlag =
false;
5565 for(
unsigned int a = 0; a < 4; a++)
5574 LinkFoundFlag =
true;
5594 bool ConnErrorFlag =
false;
5596 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5600 ConnErrorFlag =
true;
5604 ConnErrorFlag =
true;
5608 ConnErrorFlag =
true;
5612 ConnErrorFlag =
true;
5620 bool CLkErrorFlag =
false;
5622 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5626 CLkErrorFlag =
true;
5630 CLkErrorFlag =
true;
5634 CLkErrorFlag =
true;
5638 CLkErrorFlag =
true;
5656 int Position1, Position2;
5662 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
5664 int HLoc1 = GapMapPtr->first.first;
5665 int VLoc1 = GapMapPtr->first.second;
5666 int HLoc2 = GapMapPtr->second.first;
5667 int VLoc2 = GapMapPtr->second.second;
5670 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
5674 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
5678 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
5682 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
5700 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
5701 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
5711 bool FoundFlag =
false;
5723 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5724 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5725 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5754 bool FoundFlag =
false;
5767 TrackMapKeyPair.first = TrackElement.
HLoc;
5768 TrackMapKeyPair.second = TrackElement.
VLoc;
5769 TrackMapEntry.first = TrackMapKeyPair;
5774 LocationNameEntry.second = -(int)(
TrackVector.size());
5814 TrackMapKeyPair.first = HLoc;
5815 TrackMapKeyPair.second = VLoc;
5816 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5826 return(TrackMapPtr->second);
5839 TrackMapKeyPair.first = HLoc;
5840 TrackMapKeyPair.second = VLoc;
5841 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5844 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5845 throw Exception(Message);
5863 MapKeyPair.first = HLoc;
5864 MapKeyPair.second = VLoc;
5865 MapPtr = Map.find(MapKeyPair);
5866 if(MapPtr == Map.end())
5868 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc) +
" in GetTrackElementFromAnyTrackMap";
5869 throw Exception(Message);
5874 return(Vector.at(MapPtr->second));
5884 THVPair InactiveTrackMapKeyPair;
5887 InactiveTrackMapKeyPair.first = HLoc;
5888 InactiveTrackMapKeyPair.second = VLoc;
5892 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5893 throw Exception(Message);
5907 bool Present =
true;
5911 TrackMapKeyPair.first = HLoc;
5912 TrackMapKeyPair.second = VLoc;
5913 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5928 bool Present =
true;
5929 THVPair InactiveTrackMapKeyPair;
5932 InactiveTrackMapKeyPair.first = HLoc;
5933 InactiveTrackMapKeyPair.second = VLoc;
5951 THVPair InactiveTrackMapKeyPair;
5956 InactiveTrackMapKeyPair.first = HLoc;
5957 InactiveTrackMapKeyPair.second = VLoc;
5966 if(InactiveTrackRange.first == InactiveTrackRange.second)
5975 RetPair.first = InactiveTrackRange.first->second;
5976 RetPair.second = (--InactiveTrackRange.second)->second;
5989 AnsiString(DivergingPosition));
6000 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
6001 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
6002 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
6003 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
6004 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
6005 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
6006 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
6007 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
6008 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
6009 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
6010 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
6011 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
6045 throw Exception(
"Error, Wrong track type in PlotGap");
6047 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
6051 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
6055 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
6059 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
6063 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
6067 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
6071 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
6075 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
6079 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
6083 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
6087 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
6091 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
6095 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
6099 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
6103 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
6107 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
6123 PosPair.first = TrackElement.
HLoc;
6124 PosPair.second = TrackElement.
VLoc;
6128 Disp->
PlotOutput(283, TrackElement.
HLoc * 16, TrackElement.
VLoc * 16, MOMIt->second);
6141 throw Exception(
"Error, Wrong track type in PlotPoints");
6152 else if(TrackElement.
SpeedTag < 132)
6163 else if(!TrackElement.
Failed)
6170 else if(TrackElement.
SpeedTag < 132)
6188 else if(TrackElement.
SpeedTag < 132)
6222 throw Exception(
"Error, Wrong track type in PlotSignal");
6226 for(
int x = 0; x < 40; x++)
6297 for(
int x = 0; x < 40; x++)
6304 Graphics::TBitmap* SignalPlatformGraphic;
6319 for(
int x = 0; x < 8; x++)
6334 for(
int x = 0; x < 8; x++)
6425 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
6433 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
6441 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
6449 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
6465 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
6473 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
6481 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
6489 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
6522 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
6534 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
6546 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
6558 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
6600 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
6602 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6604 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
6607 if(BaseElementSpeedTag == 1)
6611 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
6618 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
6626 Graphics::TBitmap *RouteGraphic;
6628 if(TypeOfRoute == 1)
6632 else if(TypeOfRoute == 0)
6638 RouteGraphic = BaseGraphic;
6645 if(UpStep == DownStep)
6648 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
6658 else if((DownStep - UpStep) == 1)
6663 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6673 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6686 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6696 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6712 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6722 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6732 else if(DownStep == 0)
6735 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6745 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6758 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6768 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6778 for(
int x = (UpStep + 1); x < DownStep; x++)
6783 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
6787 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
6808 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
6815 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
6821 Graphics::TBitmap *RouteGraphic;
6823 if(TypeOfRoute == 1)
6827 else if(TypeOfRoute == 0)
6833 RouteGraphic = BaseGraphic;
6842 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
6852 else if((RStep - LStep) == 1)
6857 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6867 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6880 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6890 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6906 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6916 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6929 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6939 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6952 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6962 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6972 for(
int x = (LStep + 1); x < RStep; x++)
6977 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
6981 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
7005 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7008 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7010 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7012 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7015 if(BaseElementSpeedTag == 1)
7019 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
7026 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
7032 if(UpStep == DownStep)
7043 else if((DownStep - UpStep) == 1)
7062 for(
int x = (UpStep + 1); x < DownStep; x++)
7071 for(
int x = (UpStep + 1); x < DownStep; x++)
7078 for(
int x = UpStep; x <= DownStep; x++)
7091 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
7098 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
7115 else if((RStep - LStep) == 1)
7134 for(
int x = (LStep + 1); x < RStep; x++)
7143 for(
int x = (LStep + 1); x < RStep; x++)
7150 for(
int x = LStep; x <= RStep; x++)
7169 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
7171 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7173 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
7176 if(BaseElementSpeedTag == 1)
7180 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
7187 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
7193 for(
int x = UpStep; x < (DownStep + 1); x++)
7208 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
7215 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
7221 for(
int x = LStep; x < (RStep + 1); x++)
7240 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7243 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7245 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7247 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7252 if(BaseElementSpeedTag == 1)
7256 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
7263 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
7269 for(
int x = UpStep; x <= DownStep; x++)
7283 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
7290 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
7296 for(
int x = LStep; x <= RStep; x++)
7312 Graphics::TBitmap *RouteGraphic;
7315 if(BaseElementSpeedTag == 1)
7317 if(TypeOfRoute == 1)
7321 else if(TypeOfRoute == 0)
7327 RouteGraphic = BaseGraphic;
7331 RouteGraphic = BaseGraphic;
7337 if(TypeOfRoute == 1)
7341 else if(TypeOfRoute == 0)
7347 RouteGraphic = BaseGraphic;
7351 RouteGraphic = BaseGraphic;
7356 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
7361 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
7365 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
7372 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
7375 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
7380 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
7385 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
7389 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
7396 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
7399 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
7524 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7528 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7559 "," + AnsiString(VLoc));
7563 int DummyRouteNumber;
7565 TrainPresent =
false;
7569 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
7571 TrackMapKeyPair.first = HLoc;
7572 TrackMapKeyPair.second = VLoc + UpStep;
7573 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7582 TrainPresent =
true;
7596 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
7598 TrackMapKeyPair.first = HLoc;
7599 TrackMapKeyPair.second = VLoc + DownStep;
7600 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7609 TrainPresent =
true;
7623 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
7625 TrackMapKeyPair.first = HLoc + LeftStep;
7626 TrackMapKeyPair.second = VLoc;
7627 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7636 TrainPresent =
true;
7650 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
7652 TrackMapKeyPair.first = HLoc + RightStep;
7653 TrackMapKeyPair.second = VLoc;
7654 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7663 TrainPresent =
true;
7683 for(
unsigned int x = 0; x < SearchVector.size(); x++)
7700 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7703 throw Exception(
"PlotSmallFlashingLinkedLevelCrossings");
7709 while(
IsLCAtHV(61, HLoc, (VLoc + UpStep)))
7716 while(
IsLCAtHV(62, HLoc, (VLoc + DownStep)))
7722 for(
int x = UpStep; x <= DownStep; x++)
7729 while(
IsLCAtHV(63, (HLoc + LStep), VLoc))
7736 while(
IsLCAtHV(64, (HLoc + RStep), VLoc))
7742 for(
int x = LStep; x <= RStep; x++)
7758 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
7765 else if(TrackElement.
SpeedTag < 132)
7783 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7800 AnsiString(ScreenPosV));
7815 AnsiString(ScreenPosV));
7826 AnsiString(VPosTrue));
7840 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7852 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7853 " in TrackMap, Caller=" + (AnsiString)Caller);
7855 if(MapVecPos != (
int)a)
7857 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7858 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
7859 (AnsiString)Caller);
7865 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7866 " Caller=" + (AnsiString)Caller);
7886 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7887 " in InactiveMap, Caller=" + (AnsiString)Caller);
7889 if((InactivePair.first != a) && (InactivePair.second != a))
7891 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7892 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
7893 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
7898 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7899 " Caller=" + (AnsiString)Caller);
7909 int Position1, Position2;
7915 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
7917 int HLoc1 = GapMapPtr->first.first;
7918 int VLoc1 = GapMapPtr->first.second;
7919 int HLoc2 = GapMapPtr->second.first;
7920 int VLoc2 = GapMapPtr->second.second;
7923 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
7927 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
7931 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
7935 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
7939 unsigned int GapCount = 0;
7941 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7949 if((
GapMap.size() * 2) != GapCount)
7951 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
7952 (AnsiString)Caller);
7962 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
7966 throw Exception(
"Error - TrackFinished with erase element still present");
7971 AnsiString IDString;
7973 if(TrackElement.
HLoc < 0)
7975 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
7979 IDString = AnsiString(TrackElement.
HLoc) +
"-";
7981 if(TrackElement.
VLoc < 0)
7983 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
7987 IDString += AnsiString(TrackElement.
VLoc);
8002 for(
int x = 1; x < String.Length() + 1; x++)
8004 if(String.IsDelimiter(
"-", x))
8009 if(x == String.Length())
8013 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
8023 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
8028 if(DelimPos == String.Length())
8032 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
8037 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
8041 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
8048 if(String.SubString(1, 1) !=
"N")
8050 for(
int x = 1; x < DelimPos; x++)
8052 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8056 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8063 if(String.SubString(1, 1) ==
"N")
8065 for(
int x = 2; x < DelimPos; x++)
8067 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8071 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8078 if(String.SubString(1, 1) ==
"N")
8080 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
8084 HLoc = String.SubString(1, DelimPos - 1).ToInt();
8086 if(String.SubString(DelimPos + 1, 1) !=
"N")
8088 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
8090 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8094 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8101 if(String.SubString(DelimPos + 1, 1) ==
"N")
8103 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
8105 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8109 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8116 if(String.SubString(DelimPos + 1, 1) ==
"N")
8118 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
8122 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
8127 TrackMapPtr =
TrackMap.find(HVPair);
8132 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
8138 return(TrackMapPtr->second);
8140 catch(
const Exception &e)
8143 ShowMessage(
"Syntax error in track element identifier: <" + String +
">");
8157 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
8158 int HLoc = TrackElement.
HLoc;
8159 int VLoc = TrackElement.
VLoc;
8262 AnsiString(SpeedTag));
8273 if(HVRange.first == HVRange.second)
8280 HVIt1 = HVRange.first;
8285 if(--HVRange.second != HVRange.first)
8287 HVIt2 = HVRange.second;
8291 HVIt2->second).
SpeedTag == SpeedTag)))
8311 AnsiString(SpeedTag));
8377 AnsiString TestString1, TestString2;
8382 throw Exception(
"LNPendingList size not 1 on entry");
8384 int CurrentElementNumber;
8390 int H = CurrentElement->HLoc;
8391 int V = CurrentElement->VLoc;
8392 int Tag = CurrentElement->SpeedTag;
8398 for(
int x = 0; x < 25; x++)
8408 for(
int x = 0; x < 25; x++)
8418 for(
int x = 0; x < 25; x++)
8428 for(
int x = 0; x < 25; x++)
8438 for(
int x = 0; x < 28; x++)
8448 for(
int x = 0; x < 8; x++)
8458 for(
int x = 0; x < 8; x++)
8468 for(
int x = 0; x < 4; x++)
8478 for(
int x = 0; x < 8; x++)
8488 for(
int x = 0; x < 8; x++)
8501 if(CurrentElementNumber > -1)
8506 if((ExistingName !=
"") && (ExistingName != LocationName))
8522 AddName(1, CurrentElement, LocationName);
8526 LNDone2MultiMapEntry.first = HVPair;
8537 bool FoundFlag, ErasedFlag =
false;
8539 if(SNRange.first != SNRange.second)
8543 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
8550 TVIt->LocationName =
"";
8551 TVIt->ActiveTrackElementName =
"";
8584 std::pair<AnsiString, char>TempMapPair;
8592 TempMapPair.second =
'x';
8610 AnsiString(SpeedTag));
8620 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
8627 int MapPos = -1 - Position;
8631 FoundElement = MapPos;
8647 FoundElement = IMPair.first;
8656 FoundElement = IMPair.second;
8677 AnsiString OldName = TrackElement->LocationName, ErrorString;
8679 TrackElement->LocationName = Name;
8680 int HLoc = TrackElement->HLoc;
8681 int VLoc = TrackElement->VLoc;
8695 if(ErrorString !=
"")
8697 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
8721 if(LNDone2MultiMapIterator->second == MapPos)
8748 if(*LNPendingListIterator == MapPos)
8821 if(NameBeingChecked !=
"")
8827 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8835 NameBeingChecked = LNMMRg.second->first;
8837 if(NameBeingChecked !=
"")
8843 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8864 if(LNMMIt->second < 0)
8874 HVPairsLinkedMap.insert(std::pair<THVPair, bool>(HVPair,
false));
8882 std::list<THVPair> HVLinkedList;
8885 HVPairsLinkedMap.begin()->second =
true;
8886 HVLinkedList.push_back(HVPairsLinkedMap.begin()->first);
8889 THVPair HVPairUnderExamination;
8890 THVPairsLinkedMap::iterator HVPLMIt;
8892 while(!HVLinkedList.empty())
8894 HVPairUnderExamination = HVLinkedList.front();
8895 HVLinkedList.pop_front();
8896 HVPairNew.first = HVPairUnderExamination.first;
8897 HVPairNew.second = HVPairUnderExamination.second - 1;
8898 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8899 if(HVPLMIt != HVPairsLinkedMap.end())
8901 if(!HVPLMIt->second)
8903 HVLinkedList.push_back(HVPLMIt->first);
8905 HVPLMIt->second =
true;
8907 HVPairNew.first = HVPairUnderExamination.first - 1;
8908 HVPairNew.second = HVPairUnderExamination.second;
8909 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8910 if(HVPLMIt != HVPairsLinkedMap.end())
8912 if(!HVPLMIt->second)
8914 HVLinkedList.push_back(HVPLMIt->first);
8916 HVPLMIt->second =
true;
8918 HVPairNew.first = HVPairUnderExamination.first;
8919 HVPairNew.second = HVPairUnderExamination.second + 1;
8920 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8921 if(HVPLMIt != HVPairsLinkedMap.end())
8923 if(!HVPLMIt->second)
8925 HVLinkedList.push_back(HVPLMIt->first);
8927 HVPLMIt->second =
true;
8929 HVPairNew.first = HVPairUnderExamination.first + 1;
8930 HVPairNew.second = HVPairUnderExamination.second;
8931 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8932 if(HVPLMIt != HVPairsLinkedMap.end())
8934 if(!HVPLMIt->second)
8936 HVLinkedList.push_back(HVPLMIt->first);
8938 HVPLMIt->second =
true;
8943 for(THVPairsLinkedMap::iterator HVPLMIt = HVPairsLinkedMap.begin(); HVPLMIt != HVPairsLinkedMap.end(); HVPLMIt++)
8945 if(!HVPLMIt->second)
8964 if(LocationName ==
"")
8975 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8982 ActiveTrackElementNameMapEntry.second = 0;
9004 bool FoundFlag, ErasedFlag =
false;
9008 if(SNRange.first != SNRange.second)
9011 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9014 TVIt->LocationName =
"";
9015 TVIt->ActiveTrackElementName =
"";
9049 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
9051 AnsiString LocationName;
9060 if(LocationName !=
"")
9068 if(LocationName !=
"")
9082 if(LocationName !=
"")
9084 int ModifiedPosition = -1 - Position;
9093 for(
int x = 0; x < 25; x++)
9103 else if(SpeedTag == 77)
9105 for(
int x = 0; x < 25; x++)
9115 else if(SpeedTag == 78)
9117 for(
int x = 0; x < 25; x++)
9127 else if(SpeedTag == 79)
9129 for(
int x = 0; x < 25; x++)
9139 else if(SpeedTag == 96)
9141 for(
int x = 0; x < 28; x++)
9151 else if(SpeedTag == 129)
9153 for(
int x = 0; x < 8; x++)
9163 else if(SpeedTag == 130)
9165 for(
int x = 0; x < 8; x++)
9175 else if(SpeedTag == 145)
9177 for(
int x = 0; x < 8; x++)
9187 else if(SpeedTag == 146)
9189 for(
int x = 0; x < 8; x++)
9199 else if(SpeedTag == 131)
9201 for(
int x = 0; x < 4; x++)
9224 AnsiString(SpeedTag));
9236 if(TempElement->LocationName !=
"")
9238 LocationName = TempElement->LocationName;
9239 FoundElement = IMPair.first;
9247 if(TempElement->LocationName !=
"")
9249 LocationName = TempElement->LocationName;
9250 FoundElement = IMPair.second;
9262 if(TempElement->LocationName !=
"")
9264 LocationName = TempElement->LocationName;
9265 FoundElement = -1 - Position;
9281 unsigned int Count = 0;
9288 AnsiString SName, TName, ErrorString;
9290 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9296 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
9297 AnsiString(Caller));
9310 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
9311 AnsiString(Caller));
9318 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
9319 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9324 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9330 if(ErrorString !=
"")
9332 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
9334 if(SNIt->second != -1 - (
int)x)
9336 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9337 AnsiString(Caller));
9343 bool FoundFlag =
false;
9352 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackElementAt(1369, x).HLoc) +
" & V " +
9353 AnsiString(
TrackElementAt(1370, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9357 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackElementAt(1371, x).HLoc) +
9358 " & V " + AnsiString(
TrackElementAt(1372, x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
9359 AnsiString(Caller));
9364 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackElementAt(1373, x).HLoc) +
" & V " +
9365 AnsiString(
TrackElementAt(1374, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9375 if(ErrorString !=
"")
9377 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
9379 if(SNIt->second != (
int)x)
9381 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9382 AnsiString(Caller));
9392 AnsiString &ErrorString)
9400 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
9402 bool FoundFlag =
false;
9406 if(SNRange.first == SNRange.second)
9408 ErrorString =
"Error, Name " + LocationName +
" not found in map";
9410 return(SNRange.first);
9414 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9416 if(SNIterator->second < 0)
9418 int TVPos = -1 - SNIterator->second;
9420 if(TVIt == TrackElement)
9429 int ITVPos = SNIterator->second;
9431 if(ITVIt == TrackElement)
9442 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
9459 LocationNameEntry.first = NewName;
9460 LocationNameEntry.second = SNIterator->second;
9474 int TruePos = -1 - Position;
9478 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9488 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9511 InactiveTrack2MultiMapIterator++)
9513 if(InactiveTrack2MultiMapIterator->second > VecPos)
9515 InactiveTrack2MultiMapIterator->second--;
9523 LocationNameMultiMapIterator++)
9525 if(LocationNameMultiMapIterator->second < 0)
9529 if(LocationNameMultiMapIterator->second > (
int)VecPos)
9531 LocationNameMultiMapIterator->second--;
9553 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
9555 if(TrackMapIterator->second > VecPos)
9557 TrackMapIterator->second--;
9565 LocationNameMultiMapIterator++)
9567 if(LocationNameMultiMapIterator->second >= 0)
9573 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
9575 LocationNameMultiMapIterator->second++;
9579 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9585 if(TkEl.
Conn[0] ==
int(VecPos))
9590 if(TkEl.
Conn[0] >
int(VecPos))
9594 if(TkEl.
Conn[0] > -1)
9620 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
9626 LocationNameEntry.second = -1 - TVPos;
9637 LocationNameEntry.second = ITVPos;
9679 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9711 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9739 AnsiString((
short)FirstTrack));
9740 bool LengthDifferent =
false, SpeedDifferent =
false;
9747 int EXArray[16][2] =
9749 {2, 4}, {6, 2}, {8, 6}, {4, 8},
9750 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
9753 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
9754 Graphics::TBitmap *Bitmap;
9758 InLink = TrackElement.
Link[0];
9759 OutLink = TrackElement.
Link[1];
9763 InLink = TrackElement.
Link[2];
9764 OutLink = TrackElement.
Link[3];
9766 for(
int x = 0; x < 16; x++)
9768 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
9775 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLength");
9794 else if(TrackElement.
SpeedTag == 54)
9798 else if(TrackElement.
SpeedTag == 55)
9809 else if(TrackElement.
SpeedTag == 58)
9813 else if(TrackElement.
SpeedTag == 59)
9818 else if(Index == 14)
9824 else if(TrackElement.
SpeedTag == 52)
9828 else if(TrackElement.
SpeedTag == 57)
9833 else if(Index == 15)
9839 else if(TrackElement.
SpeedTag == 53)
9843 else if(TrackElement.
SpeedTag == 56)
9857 if(LengthDifferent && SpeedDifferent)
9925 else if(LengthDifferent && !SpeedDifferent)
10072 AnsiString((
short)FirstTrack));
10073 LengthDifferent =
false;
10074 SpeedDifferent =
false;
10079 LengthDifferent =
true;
10083 SpeedDifferent =
true;
10085 if(LengthDifferent || SpeedDifferent)
10098 LengthDifferent =
true;
10102 SpeedDifferent =
true;
10104 if(LengthDifferent || SpeedDifferent)
10117 LengthDifferent =
true;
10121 SpeedDifferent =
true;
10123 if(LengthDifferent || SpeedDifferent)
10203 AnsiString TempName;
10204 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
10205 bool ForwardSet, ReverseSet;
10207 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10212 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10214 ForwardSet =
false;
10215 ReverseSet =
false;
10250 for(
int y = 0; y < 2; y++)
10281 StartElement = TempElement;
10282 StartVecPos = VecPos;
10285 EntryPos = 1 - Dir;
10286 StartEntryPos = 1 - Dir;
10294 VecPos = TempElement.
Conn[1 - EntryPos];
10295 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10297 EntryPos = TempEntryPos;
10325 ForwardNumber = ((Count + 1) / 2) + 1;
10326 ReverseNumber = (Count - ForwardNumber) + 1;
10328 EntryPos = 1 - Dir;
10329 TempElement = StartElement;
10330 VecPos = StartVecPos;
10331 if(Count == ForwardNumber)
10336 if(Count == ReverseNumber)
10344 VecPos = TempElement.
Conn[1 - EntryPos];
10345 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10347 EntryPos = TempEntryPos;
10349 if(Count == ForwardNumber)
10354 if(Count == ReverseNumber)
10366 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10502 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10558 if((TextH / 16) - 1 <
HLocMin)
10562 if((TextH / 16) + 1 >
HLocMax)
10566 if((TextV / 16) - 1 <
VLocMin)
10570 if((TextV / 16) + 1 >
VLocMax)
10600 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
10601 bool &UserGraphicFoundFlag)
10604 TUserGraphicVector::iterator UserGraphicPtr;
10606 UserGraphicFoundFlag =
false;
10613 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
10614 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
10616 UserGraphicItem = x;
10617 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
10618 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
10619 UserGraphicFoundFlag =
true;
10637 int SpeedTag = TrackElement.
SpeedTag;
10641 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
10690 return(GraphicOutput);
10698 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10701 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
10714 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
10715 " in InactiveTrackElementAt");
10726 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10728 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
10753 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10754 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
10758 if(SNRange.first == SNRange.second)
10763 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10765 if(SNIterator->second < 0)
10779 HVPair.first = InactiveElement.
HLoc;
10780 HVPair.second = InactiveElement.
VLoc;
10784 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNamedLocationLongEnoughForSplit (1)");
10786 int TVPos =
TrackMap.find(HVPair)->second;
10789 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
10795 FirstNamedExitPos = 0;
10797 SecondNamedElement =
TrackElementAt(561, FirstNamedElement.
Conn[FirstNamedExitPos]);
10799 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10800 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10803 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10805 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
10806 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10807 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10810 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10820 FirstNamedExitPos = 1;
10822 SecondNamedElement =
TrackElementAt(564, FirstNamedElement.
Conn[FirstNamedExitPos]);
10824 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10825 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10828 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10830 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
10831 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10832 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10835 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10851 int &FirstNamedLinkedElementPos,
int &SecondNamedLinkedElementPos)
10865 AnsiString(FirstNamedElementPos));
10866 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10867 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
10869 SecondNamedElementPos = -1;
10870 FirstNamedLinkedElementPos = -1;
10871 SecondNamedLinkedElementPos = -1;
10875 if(SNRange.first == SNRange.second)
10880 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10882 if(SNIterator->second < 0)
10892 HVPair.first = InactiveElement.
HLoc;
10893 HVPair.second = InactiveElement.
VLoc;
10905 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in ThisNamedLocationLongEnoughForSplit (2)"
10909 int TVPos =
TrackMap.find(HVPair)->second;
10910 if(TVPos != FirstNamedElementPos)
10916 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
10922 FirstNamedExitPos = 0;
10924 SecondNamedElement =
TrackElementAt(568, FirstNamedElement.
Conn[FirstNamedExitPos]);
10926 FirstNamedLinkedElement =
TrackElementAt(569, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10927 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10930 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10932 SecondNamedLinkedElement =
TrackElementAt(570, SecondNamedElement.
Conn[SecondNamedExitPos]);
10933 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10934 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10937 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10939 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
10940 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
10941 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
10950 FirstNamedExitPos = 1;
10952 SecondNamedElement =
TrackElementAt(571, FirstNamedElement.
Conn[FirstNamedExitPos]);
10954 FirstNamedLinkedElement =
TrackElementAt(572, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10955 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10958 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10960 SecondNamedLinkedElement =
TrackElementAt(573, SecondNamedElement.
Conn[SecondNamedExitPos]);
10961 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10962 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10965 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10967 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
10968 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
10969 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
10990 if(SNRange.first != SNRange.second)
10992 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10994 if(SNIterator->second < 0)
11016 "," + AnsiString(SpeedTag));
11027 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
11057 else if(SpeedTag == 69)
11083 else if(SpeedTag == 70)
11109 else if(SpeedTag == 71)
11146 AnsiString(NextEntryPos) +
"," + AnsiString(OwnTrainID));
11147 if(NextEntryPos < 0)
11160 if(NextEntryPos > 1)
11179 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
11191 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
11192 bool FoundFlag =
false;
11207 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
11208 bool FoundFlag =
false;
11233 VPosHi = 16 * VLocHi;
11234 VPosLo = 16 * VLocLo;
11253 AnsiString(EndTVPosition));
11264 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
11265 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
11266 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
11267 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
11269 if(Link0Squares <= Link1Squares)
11287 AnsiString(LinkPos));
11306 if((LinkPos == 1) && (TE.
Attribute == 0))
11311 else if(LinkPos == 1)
11317 else if((LinkPos == 3) && (TE.
Attribute == 1))
11322 else if(LinkPos == 3)
11329 else if(LinkPos == 0)
11334 else if(LinkPos == 1)
11339 else if(LinkPos == 2)
11344 else if(LinkPos == 3)
11349 throw Exception(
"Error, failure in GetExitPos");
11398 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
11402 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
11444 "," + AnsiString(DiagonalLinkNumber));
11449 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(8, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
TrainOnLink(9, HLoc - 1, VLoc, 9, TrainID)))
11454 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(10, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
TrainOnLink(11, HLoc, VLoc - 1, 9, TrainID)))
11459 if(((DiagonalLinkNumber == 3) &&
TrainOnLink(12, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(13, HLoc + 1, VLoc, 7, TrainID)))
11464 if(((DiagonalLinkNumber == 7) &&
TrainOnLink(14, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(15, HLoc, VLoc + 1, 3, TrainID)))
11480 AnsiString JustFileName =
"";
11485 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
11492 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
11511 typedef std::list<int> TNamePosList;
11512 TNamePosList NamePosList;
11513 typedef TNamePosList::iterator TNPLIt;
11515 typedef std::list<int> TOnePlatList;
11516 TOnePlatList OnePlatList;
11517 typedef TOnePlatList::iterator TOPLIt;
11520 NamePosList.clear();
11521 OnePlatList.clear();
11522 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
11524 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
11526 NamePosList.push_back(x);
11531 if(!NamePosList.empty())
11533 OnePlatList.push_back(NamePosList.back());
11534 NamePosList.pop_back();
11536 while(!OnePlatList.empty())
11538 TempInt = OnePlatList.front();
11541 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
11542 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
11544 OnePlatList.push_back(TempElement.
Conn[0]);
11545 NamePosList.erase(NPLIt);
11547 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
11548 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
11550 OnePlatList.push_back(TempElement.
Conn[1]);
11551 NamePosList.erase(NPLIt);
11554 OnePlatList.erase(OnePlatList.begin());
11555 if(OnePlatList.empty())
11558 if(!NamePosList.empty())
11560 OnePlatList.push_back(NamePosList.back());
11561 NamePosList.pop_back();
11577 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not signal in RepairFailedSignals");
11581 throw Exception(
"Signals not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedSignals");
11609 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not points in RepairFailedPoints");
11613 throw Exception(
"Points not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedPoints");
11639 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not simple in RepairFailedPoints");
11643 throw Exception(
"No TSR at " + AnsiString(FPVIt->TVPos) +
" in RepairTSR");
11665 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
11684 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
11699 throw Exception(
"Return value negative in call to LastElementNumber");
11711 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
11725 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
11737 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
11738 " in GetModifiablePrefDirElementAt");
11748 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
11750 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
11760 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
11762 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
11779 int TrackVectorPosition;
11830 FinishElement =
false;
11831 int TrackVectorPosition;
11853 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
11863 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
11886 for(
int x = 0; x < 4; x++)
11909 FinishElement =
true;
11917 for(
int x = 0; x < 4; x++)
11929 FinishElement =
true;
11937 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
11944 .ELinkPos] ==
Lead))
11960 FinishElement =
true;
11979 FinishElement =
true;
11998 FinishElement =
true;
12013 FinishElement =
true;
12022 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12038 FinishElement =
true;
12044 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12067 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
12068 int VectorCount = 0;
12072 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
12074 for(
int x = 0; x < VectorCount; x++)
12081 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
12085 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
12086 SearchElement.
ELinkPos = NextELinkPos;
12107 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
12109 SearchElement.
XLinkPos = NextXLinkPos;
12135 for(
int x = 0; x < VectorCount; x++)
12147 for(
int x = 0; x < VectorCount; x++)
12161 for(
int x = 0; x < VectorCount; x++)
12175 for(
int x = 0; x < VectorCount; x++)
12185 for(
int x = 0; x < VectorCount; x++)
12196 SearchElement.
XLink = SearchElement.
Link[1];
12215 SearchElement.
XLink = SearchElement.
Link[3];
12228 for(
int x = 0; x < VectorCount; x++)
12243 XLinkPos = NextXLinkPos;
12244 CurrentTrackElement = SearchElement;
12263 throw Exception(
"Error, SearchVector empty");
12270 for(
int x = 0; x < 4; x++)
12323 throw Exception(
"Error in EntryExitNumber 1");
12342 if(PrefDirElement.
XLink == -1)
12354 if(PrefDirElement.
XLink != -1)
12358 throw Exception(
"Error in EntryExitNumber 2");
12396 LeadingPoints =
false;
12424 LeadingPoints =
true;
12440 AnsiString ErrorString;
12441 bool Error =
false;
12448 ErrorString =
"HLoc";
12454 ErrorString =
"VLoc";
12460 ErrorString =
"ELink";
12466 ErrorString =
"ELinkPos";
12472 ErrorString =
"XLink";
12478 ErrorString =
"XLinkPos";
12484 ErrorString =
"Tag";
12490 ErrorString =
"TrackVectorPosition";
12496 ErrorString =
"EXNumber";
12503 ErrorString =
"CheckCount";
12510 ErrorString =
"EntryGraphicPtr";
12516 ErrorString =
"EntryDirectionGraphicPtr";
12525 ErrorString =
"Last XLink not connected to this element";
12532 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
12556 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
12613 AnsiString((
short)BuildingPrefDir));
12616 if(PrefDirSize() == 0)
12621 for(
unsigned int x = 0; x < PrefDirSize(); x++)
12633 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
12645 if(x == (PrefDirSize() - 1))
12654 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
12656 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
12657 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
12658 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
12660 if(PrefDirSize() > 1)
12662 unsigned int LatestPos = PrefDirSize() - 1;
12663 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
12664 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
12665 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
12686 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12689 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12693 H = MMIT->first.first;
12694 V = MMIT->first.second;
12697 if(PrefDirPos0 > -1)
12701 if(PrefDirPos1 > -1)
12705 if(PrefDirPos2 > -1)
12709 if(PrefDirPos3 > -1)
12713 if(PrefDirPos3 > -1)
12729 else if(PrefDirPos2 > -1)
12771 else if(PrefDirPos1 > -1)
12794 else if(PrefDirPos0 > -1)
12813 int NumberOfPrefDirElements = 0;
12816 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12818 VecFile >> TempInt;
12821 VecFile >> TempInt;
12822 LoadPrefDirElement.
ELink = TempInt;
12823 VecFile >> TempInt;
12824 LoadPrefDirElement.
ELinkPos = TempInt;
12825 VecFile >> TempInt;
12826 LoadPrefDirElement.
XLink = TempInt;
12827 VecFile >> TempInt;
12828 LoadPrefDirElement.
XLinkPos = TempInt;
12829 VecFile >> TempInt;
12830 LoadPrefDirElement.
EXNumber = TempInt;
12831 VecFile >> TempInt;
12836 if(!(LoadPrefDirElement.
IsARoute))
12862 int NumberOfPrefDirElements = 0;
12865 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12867 VecFile >> TempInt;
12868 VecFile >> TempInt;
12871 VecFile >> TempInt;
12872 LoadPrefDirElement.
ELink = TempInt;
12873 VecFile >> TempInt;
12874 LoadPrefDirElement.
ELinkPos = TempInt;
12875 VecFile >> TempInt;
12876 LoadPrefDirElement.
XLink = TempInt;
12877 VecFile >> TempInt;
12878 LoadPrefDirElement.
XLinkPos = TempInt;
12879 VecFile >> TempInt;
12880 LoadPrefDirElement.
EXNumber = TempInt;
12881 VecFile >> TempInt;
12886 if(!(LoadPrefDirElement.
IsARoute))
12914 int NumberOfPrefDirElements = 0;
12917 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
12922 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12929 VecFile >> TempInt;
12930 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
12935 VecFile >> TempInt;
12936 if((TempInt < -1) || (TempInt > 9))
12941 VecFile >> TempInt;
12942 if((TempInt < -1) || (TempInt > 3))
12947 VecFile >> TempInt;
12948 if((TempInt < -1) || (TempInt > 9))
12953 VecFile >> TempInt;
12954 if((TempInt < -1) || (TempInt > 3))
12959 VecFile >> TempInt;
12960 if((TempInt < -1) || (TempInt > 27))
12965 VecFile >> TempInt;
12973 VecFile >> TempInt;
12974 if((TempInt != 0) && (TempInt != 1))
12979 VecFile >> TempInt;
12980 if((TempInt != 0) && (TempInt != 1))
12985 VecFile >> TempInt;
12986 if((TempInt != 0) && (TempInt != 1))
13009 for(
int y = 0; y < NumberOfPrefDirElements; y++)
13011 VecFile << y <<
'\n';
13012 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
13022 if(y == (NumberOfPrefDirElements - 1))
13024 VecFile <<
"************" <<
'\0' <<
'\n';
13028 VecFile <<
"******" <<
'\0' <<
'\n';
13042 for(
int y = 0; y < NumberOfSearchElements; y++)
13044 VecFile << y <<
'\n';
13045 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
13055 if(y == (NumberOfSearchElements - 1))
13057 VecFile <<
"************" <<
'\0' <<
'\n';
13061 VecFile <<
"******" <<
'\0' <<
'\n';
13174 bool AlreadyPresent, FoundFlag;
13175 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13177 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
13181 AlreadyPresent =
false;
13186 AlreadyPresent =
true;
13190 AlreadyPresent =
true;
13194 AlreadyPresent =
true;
13198 AlreadyPresent =
true;
13201 if(!AlreadyPresent)
13248 for(
unsigned int z = 0; z < 4; z++)
13256 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
13270 bool DiscrepancyFound =
false;
13281 DiscrepancyFound =
true;
13286 DiscrepancyFound =
true;
13291 DiscrepancyFound =
true;
13296 DiscrepancyFound =
true;
13301 DiscrepancyFound =
true;
13307 DiscrepancyFound =
true;
13310 if(DiscrepancyFound)
13312 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
13327 bool DiscrepancyFound =
false;
13338 DiscrepancyFound =
true;
13342 DiscrepancyFound =
true;
13347 DiscrepancyFound =
true;
13352 DiscrepancyFound =
true;
13357 DiscrepancyFound =
true;
13363 DiscrepancyFound =
true;
13367 return(!DiscrepancyFound);
13379 bool FoundFlag =
false;
13380 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
13388 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
13389 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
13391 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
13393 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
13394 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
13395 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
13400 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
13401 +
" Caller=" + (AnsiString)Caller);
13427 PrefDirMapKeyPair.first = HLoc;
13428 PrefDirMapKeyPair.second = VLoc;
13429 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13432 if(ItPair.first == ItPair.second)
13440 PrefDirPos0 = ItPair.first->second;
13442 if(ItPair.first == ItPair.second)
13447 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13449 PrefDirPos1 = ItPair.first->second;
13452 if(ItPair.first == ItPair.second)
13457 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13459 PrefDirPos2 = ItPair.first->second;
13462 if(ItPair.first == ItPair.second)
13467 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13469 PrefDirPos3 = ItPair.first->second;
13484 +
"," + AnsiString(LinkNumberPos));
13486 int PD0, PD1, PD2, PD3;
13487 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
13491 PD0, PD1, PD2, PD3);
13503 LinkedPrefDirVectorNumber = PD0;
13512 LinkedPrefDirVectorNumber = PD1;
13522 LinkedPrefDirVectorNumber = PD0;
13531 LinkedPrefDirVectorNumber = PD1;
13540 LinkedPrefDirVectorNumber = PD2;
13549 LinkedPrefDirVectorNumber = PD3;
13554 LinkedPrefDirVectorNumber = -1;
13560 LinkedPrefDirVectorNumber = -1;
13565 catch(
const Exception &e)
13567 LinkedPrefDirVectorNumber = -1;
13582 +
"," + AnsiString(LinkNumberPos));
13584 int PD0, PD1, PD2, PD3;
13585 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
13589 PD0, PD1, PD2, PD3);
13602 LinkedPrefDirVectorNumber = PD0;
13612 LinkedPrefDirVectorNumber = PD1;
13617 LinkedPrefDirVectorNumber = -1;
13625 LinkedPrefDirVectorNumber = PD0;
13634 LinkedPrefDirVectorNumber = PD1;
13643 LinkedPrefDirVectorNumber = PD2;
13652 LinkedPrefDirVectorNumber = PD3;
13657 LinkedPrefDirVectorNumber = -1;
13663 LinkedPrefDirVectorNumber = -1;
13668 catch(
const Exception &e)
13670 LinkedPrefDirVectorNumber = -1;
13682 int PD0, PD1, PD2, PD3;
13734 THVPair PrefDir4MultiMapKeyPair;
13737 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
13738 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
13739 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
13762 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
13781 AnsiString(ErasedElementNumber));
13786 if(MapPtr->second > ErasedElementNumber)
13808 throw Exception(
"PrefDirVectorPosition out of range");
13811 THVPair PrefDir4MultiMapKeyPair;
13813 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
13814 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
13815 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13818 if(ItPair.first == ItPair.second)
13821 return(ItPair.first);
13825 if(ItPair.first->second == PrefDirVectorPosition)
13829 return(ItPair.first);
13832 if(ItPair.first == ItPair.second)
13835 return(ItPair.first);
13837 if(ItPair.first->second == PrefDirVectorPosition)
13841 return(ItPair.first);
13844 if(ItPair.first == ItPair.second)
13847 return(ItPair.first);
13849 if(ItPair.first->second == PrefDirVectorPosition)
13853 return(ItPair.first);
13856 if(ItPair.first == ItPair.second)
13859 return(ItPair.first);
13861 if(ItPair.first->second == PrefDirVectorPosition)
13865 return(ItPair.first);
13869 return(ItPair.first);
13882 THVPair PrefDir4MultiMapKeyPair;
13884 PrefDir4MultiMapKeyPair.first = HLoc;
13885 PrefDir4MultiMapKeyPair.second = VLoc;
13886 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13889 if(ItPair.first == ItPair.second)
13897 return(ItPair.first->second);
13906 bool ErasedFlag =
false;
13908 if(ErasedTrackVectorPosition > -1)
13917 ErasedFlag =
false;
13919 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
13924 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
13929 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
13934 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
13939 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
13947 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
13951 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
13955 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
13959 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
13963 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
13978 OverallDistance = 0;
13979 OverallSpeedLimit = 0;
13980 LeadingPointsAtLastElement =
false;
13988 LeadingPointsAtLastElement =
true;
13997 OverallDistance += PrefDirElement.
Length23;
13998 if(OverallSpeedLimit != -1)
14008 OverallSpeedLimit = -1;
14015 OverallDistance += PrefDirElement.
Length01;
14016 if(OverallSpeedLimit != -1)
14026 OverallSpeedLimit = -1;
14045 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14048 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14052 HLoc = MMIT->first.first;
14053 VLoc = MMIT->first.second;
14058 if(PrefDirPos0 > -1)
14062 if(PrefDirPos1 > -1)
14066 if(PrefDirPos2 > -1)
14070 if(PrefDirPos3 > -1)
14074 if(PrefDirPos3 > -1)
14077 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14079 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14081 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14083 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
14090 else if(PrefDirPos2 > -1)
14095 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14097 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14099 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
14108 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14110 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14112 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
14121 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14123 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14125 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14132 else if(PrefDirPos1 > -1)
14137 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14139 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14147 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14149 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
14155 else if(PrefDirPos0 > -1)
14157 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14174 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14177 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14199 if(PrefDirPos0 > -1)
14203 if(PrefDirPos1 > -1)
14207 if(PrefDirPos2 > -1)
14211 if(PrefDirPos3 > -1)
14215 if(PrefDirPos3 > -1)
14220 else if(PrefDirPos2 > -1)
14222 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
14233 else if(PrefDirPos1 > -1)
14235 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
14246 else if(PrefDirPos0 > -1)
14248 if(PrefDirElement0.
XLinkPos == EntryPos)
14285 ElementIn.
VLoc +
"," + XLink);
14287 bool TrackFoundFlag;
14290 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
14302 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
14312 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
14326 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
14336 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
14350 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
14360 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
14374 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
14384 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
14407 bool FoundFlag, ContFlag, FoundElements =
false;
14408 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14413 LastIteratorValue++;
14439 if(PDVIt->XLinkPos == 0)
14444 StartElement = *PDVIt;
14453 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
14455 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14456 if(PrefDirPos0 == -1)
14460 bool NextElementFoundFlag =
false;
14464 NextElementFoundFlag =
true;
14466 if(PrefDirPos1 > -1)
14471 NextElementFoundFlag =
true;
14474 if(PrefDirPos2 > -1)
14479 NextElementFoundFlag =
true;
14482 if(PrefDirPos3 > -1)
14487 NextElementFoundFlag =
true;
14490 if(!NextElementFoundFlag)
14520 EndElement = NextElement;
14524 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
14526 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14527 if(PrefDirPos0 == -1)
14537 if(PrefDirPos1 > -1)
14545 if(PrefDirPos2 > -1)
14553 if(PrefDirPos3 > -1)
14584 FoundElements =
true;
14618 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
14620 int TrackVectorPosition;
14656 int LockedVectorNumber;
14679 bool InPrefDirFlag =
false;
14682 int PrefDirPos0 = -1;
14683 int PrefDirPos1 = -1;
14684 int PrefDirPos2 = -1;
14685 int PrefDirPos3 = -1;
14689 int PrefDirVecPos[4] =
14691 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14694 for(
int x = 0; x < 4; x++)
14696 int b = PrefDirVecPos[x];
14706 InPrefDirFlag =
true;
14719 TrainController->
StopTTClockMessage(12,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
14727 if(DummyPair.first > -1)
14729 throw Exception(
"Selection in two routes - should never happen!");
14731 if(RoutePair.first > -1)
14807 IDInt &ReqPosRouteID,
bool &PointsChanged)
14841 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignals) +
"," + AnsiString((
short)AutoSigsFlag));
14843 int NewFailedPointsTVPos = -1;
14892 bool InPrefDirFlag =
false;
14895 int PrefDirPos0 = -1;
14896 int PrefDirPos1 = -1;
14897 int PrefDirPos2 = -1;
14898 int PrefDirPos3 = -1;
14901 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14902 int PrefDirVecPos[4] =
14904 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14907 for(
int x = 0; x < 4; x++)
14909 int b = PrefDirVecPos[x];
14912 InPrefDirFlag =
true;
14925 TrainController->
StopTTClockMessage(23,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
14934 if(RoutePair.first > -1)
14936 if(RoutePair.second != 0)
14953 EndElement1 = RouteElement;
14954 EndElement2 = BlankElement;
15049 AutoSigsFlag,
false))
15054 if(NewFailedPointsTVPos > -1)
15058 " failed during route setting.");
15062 PointsChanged =
true;
15085 AutoSigsFlag,
false))
15090 if(NewFailedPointsTVPos > -1)
15094 " failed during route setting.");
15098 PointsChanged =
true;
15116 AutoSigsFlag,
false))
15121 if(NewFailedPointsTVPos > -1)
15125 " failed during route setting.");
15129 PointsChanged =
true;
15153 AutoSigsFlag,
false))
15158 if(NewFailedPointsTVPos > -1)
15162 " failed during route setting.");
15166 PointsChanged =
true;
15175 AutoSigsFlag,
false))
15180 if(NewFailedPointsTVPos > -1)
15184 " failed during route setting.");
15188 PointsChanged =
true;
15199 AutoSigsFlag,
false))
15204 if(NewFailedPointsTVPos > -1)
15208 " failed during route setting.");
15212 PointsChanged =
true;
15218 AutoSigsFlag,
false))
15223 if(NewFailedPointsTVPos > -1)
15227 " failed during route setting.");
15231 PointsChanged =
true;
15242 AutoSigsFlag,
false))
15247 if(NewFailedPointsTVPos > -1)
15251 " failed during route setting.");
15255 PointsChanged =
true;
15309 TOnePrefDir *EveryPrefDir,
bool ConsecSignals,
int EndPosition,
bool AutoSigsFlag,
bool RecursiveCall)
15361 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
15362 AnsiString((
short)AutoSigsFlag) +
"," + AnsiString((
short)RecursiveCall));
15363 int VectorCount = 0;
15372 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
15376 for(
int x = 0; x < VectorCount; x++)
15384 bool FirstPass =
true;
15394 for(
int x = 0; x < VectorCount; x++)
15403 for(
int x = 0; x < VectorCount; x++)
15415 for(
int x = 0; x < VectorCount; x++)
15423 int NextPosition = PrefDirElement.
Conn[XLinkPos];
15427 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
15428 SearchElement.
ELinkPos = NextELinkPos;
15429 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
15450 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
15452 SearchElement.
XLinkPos = NextXLinkPos;
15480 if(RoutePair.first > -1)
15489 for(
int x = 0; x < VectorCount; x++)
15498 if(SecondPair.first > -1)
15507 for(
int x = 0; x < VectorCount; x++)
15521 for(
int x = 0; x < VectorCount; x++)
15532 for(
int x = 0; x < VectorCount; x++)
15541 for(
int x = 0; x < VectorCount; x++)
15550 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15554 for(
int x = 0; x < VectorCount; x++)
15564 bool InPrefDirFlag =
false;
15565 PrefDirElement1 = BlankElement;
15566 PrefDirElement2 = BlankElement;
15569 int PrefDirPos0 = -1;
15570 int PrefDirPos1 = -1;
15571 int PrefDirPos2 = -1;
15572 int PrefDirPos3 = -1;
15575 int PrefDirVecPos[4] =
15577 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
15579 for(
int x = 0; x < 4; x++)
15581 int b = PrefDirVecPos[x];
15584 InPrefDirFlag =
true;
15597 for(
int x = 0; x < VectorCount; x++)
15609 for(
int x = 0; x < VectorCount; x++)
15625 for(
int x = 0; x < VectorCount; x++)
15636 for(
int x = 0; x < VectorCount; x++)
15656 for(
int x = 0; x < VectorCount; x++)
15669 for(
int x = 0; x < VectorCount; x++)
15683 for(
int x = 0; x < VectorCount; x++)
15693 for(
int x = 0; x < VectorCount; x++)
15724 for(
int x = 0; x < VectorCount; x++)
15733 for(
int x = 0; x < VectorCount; x++)
15745 int SearchPos1 = SearchElement.
Attribute + 1;
15747 if(SearchPos1 == 2)
15751 if(SearchPos1 == 1)
15759 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
15760 SearchElement.
XLinkPos = SearchPos1;
15761 InPrefDirFlag =
false;
15762 if(SearchElement.
XLink == PrefDirElement1.
XLink)
15764 SearchElement = PrefDirElement1;
15765 InPrefDirFlag =
true;
15767 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
15769 SearchElement = PrefDirElement2;
15770 InPrefDirFlag =
true;
15776 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15780 for(
int x = 0; x < VectorCount; x++)
15798 AutoSigsFlag,
true))
15807 for(
int x = 0; x < VectorCount; x++)
15816 for(
int x = 0; x < VectorCount; x++)
15836 for(
int x = 0; x < VectorCount; x++)
15846 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
15847 SearchElement.
XLinkPos = SearchPos2;
15848 if(SearchElement.
XLink == PrefDirElement1.
XLink)
15850 SearchElement = PrefDirElement1;
15852 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
15854 SearchElement = PrefDirElement2;
15858 for(
int x = 0; x < VectorCount; x++)
15866 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15870 for(
int x = 0; x < VectorCount; x++)
15889 AutoSigsFlag,
true))
15898 for(
int x = 0; x < VectorCount; x++)
15907 for(
int x = 0; x < VectorCount; x++)
15919 for(
int x = 0; x < VectorCount; x++)
15929 SearchElement = PrefDirElement1;
15938 XLinkPos = SearchElement.
XLinkPos;
15939 PrefDirElement = SearchElement;
15996 unsigned int TruncatePrefDirPosition = 0;
16069 throw Exception(
"Error - failed to validate extended route for preferred route");
16124 throw Exception(
"Error - failed to validate single route for preferred route");
16169 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
16171 int TrackVectorPosition;
16208 int LockedVectorNumber;
16242 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
16243 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
16246 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
16252 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
16253 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
16256 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
16270 if(RoutePair.first > -1)
16405 int NewFailedPointsTVPos = -1;
16470 EndElement1.
ELink = EndElement1.
Link[0];
16471 EndElement1.
XLink = EndElement1.
Link[1];
16474 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
16479 EndElement2.
ELink = EndElement2.
Link[1];
16480 EndElement2.
XLink = EndElement2.
Link[0];
16483 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
16527 if(RoutePair.first > -1)
16529 if(RoutePair.second != 0)
16552 EndElement2 = BlankElement;
16637 if(NewFailedPointsTVPos > -1)
16641 " failed during route setting.");
16645 PointsChanged =
true;
16671 if(NewFailedPointsTVPos > -1)
16675 " failed during route setting.");
16679 PointsChanged =
true;
16701 if(NewFailedPointsTVPos > -1)
16705 " failed during route setting.");
16709 PointsChanged =
true;
16735 if(NewFailedPointsTVPos > -1)
16739 " failed during route setting.");
16743 PointsChanged =
true;
16757 if(NewFailedPointsTVPos > -1)
16761 " failed during route setting.");
16765 PointsChanged =
true;
16805 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
16806 int VectorCount = 0;
16809 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
16810 (CurrentTrackElement.
Link[XLinkPos] == 9))
16814 for(
int x = 0; x < VectorCount; x++)
16826 for(
int x = 0; x < VectorCount; x++)
16833 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
16835 for(
int x = 0; x < VectorCount; x++)
16842 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
16846 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
16847 SearchElement.
ELinkPos = NextELinkPos;
16868 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
16870 SearchElement.
XLinkPos = NextXLinkPos;
16898 if(RoutePair.first > -1)
16907 for(
int x = 0; x < VectorCount; x++)
16916 if(SecondPair.first > -1)
16925 for(
int x = 0; x < VectorCount; x++)
16939 for(
int x = 0; x < VectorCount; x++)
16950 for(
int x = 0; x < VectorCount; x++)
16959 for(
int x = 0; x < VectorCount; x++)
16968 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16972 for(
int x = 0; x < VectorCount; x++)
16985 for(
int x = 0; x < VectorCount; x++)
17013 for(
int x = 0; x < VectorCount; x++)
17026 for(
int x = 0; x < VectorCount; x++)
17036 for(
int x = 0; x < VectorCount; x++)
17061 for(
int x = 0; x < VectorCount; x++)
17070 for(
int x = 0; x < VectorCount; x++)
17083 int SearchPos1 = SearchElement.
Attribute + 1;
17085 if(SearchPos1 == 2)
17089 if(SearchPos1 == 1)
17098 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
17099 SearchElement.
XLinkPos = SearchPos1;
17101 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17105 for(
int x = 0; x < VectorCount; x++)
17123 for(
int x = 0; x < VectorCount; x++)
17139 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
17140 SearchElement.
XLinkPos = SearchPos2;
17142 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17146 for(
int x = 0; x < VectorCount; x++)
17162 for(
int x = 0; x < VectorCount; x++)
17174 for(
int x = 0; x < VectorCount; x++)
17189 CurrentTrackElement = SearchElement;
17190 XLinkPos = SearchElement.
XLinkPos;
17212 throw Exception(
"Error, SearchVector empty");
17224 for(
int x = 0; x < 4; x++)
17266 throw Exception(
"Error in EntryExitNumber 3");
17321 unsigned int TruncatePrefDirPosition = 0;
17381 throw Exception(
"Failed to validate extended route for nonpreferred route");
17426 throw Exception(
"Failed to validate single route for nonpreferred route");
17446 if(!PrefDirVector.empty())
17450 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
17455 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
17472 if(!PrefDirVector.empty())
17477 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
17494 NewFailedPointsTVPos = -1;
17495 bool PointsChanged =
false;
17503 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
17513 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
17514 IFE.
TVPos = NewFailedPointsTVPos;
17533 PointsChanged =
true;
17536 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
17546 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
17547 IFE.
TVPos = NewFailedPointsTVPos;
17566 PointsChanged =
true;
17572 return(PointsChanged);
17596 NextForwardLinkedRouteNumber = -1;
17597 for(
unsigned int x = StartPos; x < PrefDirSize(); x++)
17599 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
17600 if(PrefDirVector.at(x).TrackType ==
Bridge)
17602 if(PrefDirVector.at(x).XLinkPos < 2)
17604 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit01;
17608 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit23;
17616 if(PrefDirVector.at(x).TrackType ==
Buffers)
17628 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
17637 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
17639 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute;
17651 if(x == PrefDirSize() - 1)
17654 NextForwardLinkedRouteNumber = -1;
17702 AnsiString(PrefDirVectorStartPosition));
17708 if(!PrefDirVector.empty())
17710 if(!SkipForwardLook)
17712 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
17715 if(PrefDirPtr->TrackType ==
Bridge)
17717 if(PrefDirPtr->XLinkPos < 2)
17728 SkipForwardLook =
true;
17736 SkipForwardLook =
true;
17739 int NextForwardLinkedRouteNumber = -1;
17740 if((
unsigned int)PrefDirVectorStartPosition == PrefDirSize() - 1)
17742 TPrefDirElement PDE = GetFixedPrefDirElementAt(267, PrefDirVectorStartPosition);
17747 SkipForwardLook =
true;
17748 if(PrefDirVector.back().TrackType ==
Buffers)
17754 bool SetAttributeTo3 =
true;
17765 SetAttributeTo3 =
false;
17766 Attribute = AutoSigVectorIT->AccessNumber;
17772 if(SetAttributeTo3)
17783 SkipForwardLook =
true;
17784 if(PrefDirVector.back().TrackType ==
Buffers)
17797 if(!SkipForwardLook)
17802 if((
unsigned int)PrefDirVectorStartPosition < (PrefDirSize() - 1))
17804 StartPos = PrefDirVectorStartPosition + 1;
17812 if(!FindForwardTargetSignalAttribute(2, NextForwardLinkedRouteNumber, Attribute, StartPos))
17831 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
17834 if(PrefDirPtr->TrackType ==
Bridge)
17836 if(PrefDirPtr->XLinkPos < 2)
17852 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
17861 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
17864 PrefDirPtr->PrefDirRoute)
17868 int LockedVecNum = 0;
17870 bool KeepAttributeAt0ForLockedRoute =
false;
17875 KeepAttributeAt0ForLockedRoute =
true;
17880 bool NotGroundSignal =
false;
17883 NotGroundSignal =
true;
17908 if((Attribute < 3) && !KeepAttributeAt0ForLockedRoute && (NotGroundSignal || (Attribute == 0)))
17937 "," + AnsiString((
short)PrefDirRoute));
17938 bool ElementInRoute =
false;
17939 bool MovingTrainOccupyingRoute =
false;
17940 unsigned int TruncatePDElementPos;
17941 enum {NoTruncate, BackTruncate, FrontTruncate, FullTruncate} TruncateType;
17942 TruncateType = NoTruncate;
17949 TruncatePDElementPos = b;
17950 ElementInRoute =
true;
17954 if(!ElementInRoute)
17964 if(TruncatePDElementPos == 0)
17966 TruncateType = FullTruncate;
17974 TruncateType = FrontTruncate;
17978 TruncateType = BackTruncate;
17985 TruncateType = BackTruncate;
17991 if(TruncateType == BackTruncate)
18011 MovingTrainOccupyingRoute =
true;
18022 if(b ==
int(TruncatePDElementPos))
18028 else if(TruncateType == FrontTruncate)
18048 MovingTrainOccupyingRoute =
true;
18059 if(b == TruncatePDElementPos)
18085 MovingTrainOccupyingRoute =
true;
18107 if(((TruncatePDElementPos == 1) && (TruncateType == BackTruncate)) || ((TruncatePDElementPos == (
PrefDirSize() - 2)) && (TruncateType == FrontTruncate)))
18116 if((TruncatePDElementPos > 0) && (TruncateType == BackTruncate))
18123 TrainController->
StopTTClockMessage(145,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18124 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18125 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18145 else if((TruncatePDElementPos < (
PrefDirSize() - 1)) && (TruncateType == FrontTruncate))
18152 TrainController->
StopTTClockMessage(146,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18153 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18154 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18163 if(TruncatePDElementPos > 0)
18178 else if(TruncatePDElementPos == 0)
18185 TrainController->
StopTTClockMessage(148,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18186 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18187 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18207 int ThisRouteNumber;
18217 if(LRVIT->RouteNumber == ThisRouteNumber)
18228 unsigned int LookBackwardsFromHere = 0;
18229 if(TruncateType == BackTruncate)
18231 LookBackwardsFromHere = TruncatePDElementPos;
18243 int button = Application->MessageBox(L
"Moving train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
18244 L
"Warning!", MB_YESNO | MB_ICONWARNING);
18257 bool ExistingLockedRouteModified =
false;
18259 if(TruncateType == BackTruncate)
18265 else if(TruncateType == FrontTruncate)
18286 if(LRVIT->RouteNumber == ThisRouteNumber)
18290 ExistingLockedRouteModified =
true;
18294 if(!ExistingLockedRouteModified)
18298 if(TruncateType == BackTruncate)
18301 RearPosition = TruncatePDElementPos;
18304 else if(TruncateType == FrontTruncate)
18308 FrontPosition = TruncatePDElementPos;
18317 for(
int c = FrontPosition; c >= RearPosition; c--)
18335 if(TruncateType == BackTruncate)
18337 RearPosition = TruncatePDElementPos;
18341 else if(TruncateType == FrontTruncate)
18344 FrontPosition = TruncatePDElementPos;
18361 for(
int c = FrontPosition; c >= RearPosition; c--)
18405 TPrefDirElement NewGreenFirstPDElement, NewRedFirstPDElement, NewGreenLastPDElement, NewRedLastPDElement;
18418 if(RouteColour == 1)
18420 NewRedFirstPDElement = LastPDElement;
18424 NewRedFirstPDElement.
IsARoute =
true;
18430 if(R2MMIt->second.first ==
int(x))
18432 R2MMIt->second.second++;
18439 else if(RouteColour == 2)
18441 NewGreenFirstPDElement = LastPDElement;
18445 NewGreenFirstPDElement.
IsARoute =
true;
18451 if(R2MMIt->second.first ==
int(x))
18453 R2MMIt->second.second++;
18476 if(RouteColour == 1)
18478 NewRedLastPDElement = FirstPDElement;
18487 else if(RouteColour == 2)
18489 NewGreenLastPDElement = FirstPDElement;
18558 ARVIt->SetRouteSignals(14);
18577 AnsiString((
short)PrefDirRoute));
18602 AnsiString((
short)PrefDirRoute));
18612 RouteFlashElement.
HLoc = H;
18613 RouteFlashElement.
VLoc = V;
18629 int H = PrefDirPtr->HLoc;
18630 int V = PrefDirPtr->VLoc;
18697 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
18703 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
18706 OverlayPlotted =
false;
18729 bool FirstSignalFound =
false;
18736 if(PDVIt->TrackType ==
Points)
18738 if((PDVIt->ELinkPos == 1) || (PDVIt->XLinkPos == 1))
18749 else if((PDVIt->ELinkPos == 3) || (PDVIt->XLinkPos == 3))
18764 int XLinkPosition = PDVIt->XLinkPos;
18765 if(PDVIt->XLinkPos == -1)
18769 for(
int x = 0; x < 4; x++)
18771 if(PDVIt->Conn[x] == (PDVIt + 1)->TrackVectorPosition)
18784 if(XLinkPosition > -1)
18786 if(!FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
18788 FirstSignalFound =
true;
18791 else if(FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
18802 IFE.
TVPos = PDVIt->TrackVectorPosition;
18808 " failed when changing aspect.\nTrains can only pass under signaller control.");
18838 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
18840 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
18843 return(AllRoutesVector.at(At));
18851 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
18853 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
18856 return(AllRoutesVector.at(At));
18867 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18869 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
18879 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18881 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
18899 AnsiString(VLoc) +
"," + AnsiString((
short)PrefDirRoute));
18900 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18904 GetModifiableRouteAt(7, a).TruncateRoute(0, HLoc, VLoc, PrefDirRoute, ReturnFlag);
18933 AnsiString(LinkPos));
18934 if(TrackVectorPosition == -1)
18939 THVPair Route2MultiMapKeyPair;
18943 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
18946 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
18956 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
18958 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
18961 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
18962 Route2MultiMapIterator->second.second);
18963 EntryLinkPos = PrefDirElement1.
ELinkPos;
18964 ExitLinkPos = PrefDirElement1.
XLinkPos;
18965 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
18966 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
18978 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
18990 Graphics::TBitmap* &EntryDirectionGraphicPtr)
19000 AnsiString(LinkPos));
19003 if(TrackVectorPosition == -1)
19008 THVPair Route2MultiMapKeyPair;
19012 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
19015 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19020 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19022 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19024 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
19025 Route2MultiMapIterator->second.second);
19026 EntryLinkPos = PrefDirElement1.
ELinkPos;
19027 ExitLinkPos = PrefDirElement1.
XLinkPos;
19028 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
19029 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
19033 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
19034 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
19041 return(AutoSigsRoute);
19046 return(NotAutoSigsRoute);
19052 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
19053 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
19060 return(AutoSigsRoute);
19065 return(NotAutoSigsRoute);
19069 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19071 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19072 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19074 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
19075 EntryLinkPos = PrefDirElement2.
ELinkPos;
19076 ExitLinkPos = PrefDirElement2.
XLinkPos;
19077 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
19078 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
19082 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
19089 return(AutoSigsRoute);
19094 return(NotAutoSigsRoute);
19100 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
19107 return(AutoSigsRoute);
19112 return(NotAutoSigsRoute);
19116 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
19117 EntryLinkPos = PrefDirElement3.
ELinkPos;
19118 ExitLinkPos = PrefDirElement3.
XLinkPos;
19119 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
19120 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
19124 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
19131 return(AutoSigsRoute);
19136 return(NotAutoSigsRoute);
19142 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
19149 return(AutoSigsRoute);
19154 return(NotAutoSigsRoute);
19170 AnsiString(LinkPos));
19171 if(TrackVectorPosition == -1)
19177 THVPair Route2MultiMapKeyPair;
19181 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
19184 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19190 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19192 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19194 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
19195 Route2MultiMapIterator->second.second);
19196 EntryLinkPos = PrefDirElement1.
ELinkPos;
19197 ExitLinkPos = PrefDirElement1.
XLinkPos;
19198 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
19199 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
19202 RouteNumber = Route2MultiMapIterator->second.first;
19206 return(AutoSigsRoute);
19211 return(NotAutoSigsRoute);
19216 RouteNumber = Route2MultiMapIterator->second.first;
19220 return(AutoSigsRoute);
19225 return(NotAutoSigsRoute);
19229 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19231 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19232 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19234 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
19235 EntryLinkPos = PrefDirElement2.
ELinkPos;
19236 ExitLinkPos = PrefDirElement2.
XLinkPos;
19237 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
19238 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
19241 RouteNumber = ItPair.first->second.first;
19245 return(AutoSigsRoute);
19250 return(NotAutoSigsRoute);
19255 RouteNumber = ItPair.first->second.first;
19259 return(AutoSigsRoute);
19264 return(NotAutoSigsRoute);
19268 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
19269 EntryLinkPos = PrefDirElement3.
ELinkPos;
19270 ExitLinkPos = PrefDirElement3.
XLinkPos;
19271 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
19272 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
19275 RouteNumber = ItPair.second->second.first;
19279 return(AutoSigsRoute);
19284 return(NotAutoSigsRoute);
19289 RouteNumber = ItPair.second->second.first;
19293 return(AutoSigsRoute);
19298 return(NotAutoSigsRoute);
19320 EmptyRoute.
RouteID = NextRouteID;
19323 AllRoutesVector.push_back(EmptyRoute);
19324 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
19349 AllRoutesVector.push_back(EmptyRoute);
19350 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
19373 THVPair Route2MultiMapKeyPair;
19382 LockedRouteRearTrackVectorPosition = 0;
19383 LockedRouteLastTrackVectorPosition = 0;
19384 LockedRouteLastXLinkPos = 0;
19385 LockedRouteLockStartTime = TDateTime(0);
19386 if(!LockedRouteVector.empty())
19390 if(LRVIT->RouteNumber == RouteNumber)
19392 LockedRouteRearTrackVectorPosition = LRVIT->RearTrackVectorPosition;
19393 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
19394 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
19395 LockedRouteLockStartTime = LRVIT->LockStartTime;
19396 LockedRouteFoundDuringRouteBuilding =
true;
19397 LockedRouteVector.erase(LRVIT);
19422 AnsiString(VLoc) +
"," + AnsiString(ELink));
19425 ReturnPair.first = -1;
19426 ReturnPair.second = 0;
19427 THVPair Route2MultiMapKeyPair;
19429 Route2MultiMapKeyPair.first = HLoc;
19430 Route2MultiMapKeyPair.second = VLoc;
19433 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
19434 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19436 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19437 Route2MultiMapIterator = ItPair.first;
19439 if(ItPair.first == ItPair.second)
19441 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
19443 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
19445 ReturnPair.first = ItPair.first->second.first;
19446 ReturnPair.second = ItPair.first->second.second;
19447 Route2MultiMapIterator = ItPair.first;
19449 return(ReturnPair);
19452 if(ItPair.first == ItPair.second)
19454 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
19456 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
19458 ReturnPair.first = ItPair.first->second.first;
19459 ReturnPair.second = ItPair.first->second.second;
19460 Route2MultiMapIterator = ItPair.first;
19462 return(ReturnPair);
19465 return(ReturnPair);
19480 AnsiString(VLoc) +
"," + AnsiString(ELink));
19481 THVPair Route2MultiMapKeyPair;
19483 Route2MultiMapKeyPair.first = HLoc;
19484 Route2MultiMapKeyPair.second = VLoc;
19485 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19487 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19489 if(ItPair.first == ItPair.second)
19495 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
19497 RouteNumber = ItPair.first->second.first;
19503 if(ItPair.first == ItPair.second)
19509 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
19511 RouteNumber = ItPair.first->second.first;
19532 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
19533 THVPair Route2MultiMapKeyPair;
19535 Route2MultiMapKeyPair.first = HLoc;
19536 Route2MultiMapKeyPair.second = VLoc;
19539 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
19542 RouteElementPair.first = RouteNumber;
19543 RouteElementPair.second = RouteElementNumber;
19544 Route2MultiMapEntry.second = RouteElementPair;
19546 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
19549 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
19550 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
19553 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
19554 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
19556 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
19558 Route2MultiMap.insert(Route2MultiMapEntry);
19563 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
19568 Route2MultiMap.insert(Route2MultiMapEntry);
19586 TempPair.first = -1;
19587 TempPair.second = 0;
19588 SecondPair = TempPair;
19590 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
19591 THVPair Route2MultiMapKeyPair;
19593 Route2MultiMapKeyPair.first = HLoc;
19594 Route2MultiMapKeyPair.second = VLoc;
19595 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19600 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19602 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19604 return(Route2MultiMapIterator->second);
19606 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19608 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19609 TempPair = ItRange.first->second;
19610 SecondPair = (--ItRange.second)->second;
19633 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
19634 if(RouteElementPair.first == -1)
19637 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
19638 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
19640 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
19643 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
19644 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
19645 (AnsiString)Caller);
19647 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
19650 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
19651 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
19652 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
19653 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
19657 unsigned int SizeVal = 0;
19660 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
19662 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
19664 if(SizeVal != Route2MultiMap.size())
19666 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
19667 (AnsiString)Caller);
19683 if(!Route2MultiMap.empty())
19685 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
19687 if(Route2MultiMapIterator->second.first > RouteNumber)
19689 Route2MultiMapIterator->second.first--;
19706 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
19707 if(!Route2MultiMap.empty())
19709 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
19711 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
19713 Route2MultiMapIterator->second.second--;
19732 AnsiString(ELink));
19736 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
19737 if(RequiredRoutePair.first == -1)
19739 throw Exception(
"Failed to find route element in RemoveRouteElement");
19741 Route2MultiMap.erase(Route2MultiMapIterator);
19742 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
19745 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
19766 GetModifiableRouteAt(8, RequiredRoutePair.first).PrefDirVector.erase(GetModifiableRouteAt(33, RequiredRoutePair.first).PrefDirVector.begin() + RequiredRoutePair.second);
19777 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
19785 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
19787 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
19788 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
19789 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
19801 if(!LockedRouteVector.empty())
19805 if(LRVIT->RouteNumber > RequiredRoutePair.first)
19807 LRVIT->RouteNumber--;
19817 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
19819 AutoSigVectorIT->RouteNumber--;
19824 CheckMapAndRoutes(7);
19838 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
19839 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
19840 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
19857 "," + AnsiString(XLinkPos));
19861 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
19862 if(RouteElementPair.first == -1)
19864 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
19866 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
19868 RequiredPair = RouteElementPair;
19869 if(RouteElement.
XLinkPos != XLinkPos)
19871 if(SecondPair.first != -1)
19873 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
19874 RequiredPair = SecondPair;
19875 if(RouteElement.
XLinkPos != XLinkPos)
19877 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
19882 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
19886 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
19907 AnsiString(AccessNumber));
19909 int Attribute = AccessNumber;
19911 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
19915 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
19919 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
19922 x).XLinkPos] !=
End)
19924 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
19927 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
19978 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
19979 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
19980 int RearwardLinkedRouteNumber;
19983 bool SkipForwardLook =
false;
19992 SkipForwardLook =
true;
19994 RearwardLinkedRouteNumber).
PrefDirSize() - 1, SkipForwardLook)))
20004 int TrainID, TrainPosition, BehindTrainPosition;
20005 bool FoundTrain =
false, BehindTrain =
false;
20006 for(
int x = RouteStartPosition; x >= 0; x--)
20008 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
20033 if(FoundTrain && (TrainPosition > 1))
20037 for(
int x = TrainPosition; x >= 0; x--)
20041 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
20061 BehindTrain =
true;
20062 BehindTrainPosition = x;
20069 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
20086 AnsiString(LookBackwardsFromHere));
20087 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber;
20088 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
20091 bool ExamineRoute =
true;
20093 while(ExamineRoute)
20095 for(
int x = LookBackwardsFromHere; x >= 0; x--)
20140 if(SignalCount >= 3)
20155 LookBackwardsFromHere = CurrentRoute.
PrefDirSize() - 1;
20159 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
20160 ExamineRoute =
true;
20161 LookBackwardsFromHere = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
20196 ExamineRoute =
false;
20211 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
20214 PrefDirElement = InternalPrefDirElement;
20215 if(LockedRouteVector.empty())
20222 bool InLockedRoute =
false;
20226 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
20230 InLockedRoute =
true;
20239 int RouteNumber, VectorCount = 0;
20244 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
20245 if(RouteType == NoRoute)
20258 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
20260 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
20265 PrefDirElement = InternalPrefDirElement;
20266 LockedVectorNumber = VectorCount;
20271 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->RearTrackVectorPosition)
20275 PrefDirElement = InternalPrefDirElement;
20276 LockedVectorNumber = VectorCount;
20297 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20299 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
20305 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
20315 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20317 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
20332 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20334 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
20337 return(GetFixedRouteAt(159, x));
20340 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
20348 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20350 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
20353 return(GetModifiableRouteAt(15, x));
20356 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
20366 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20368 TOneRoute OneRoute = GetFixedRouteAt(165, x);
20380 int NumberOfRoutes;
20384 for(
int x = 0; x < NumberOfRoutes; x++)
20391 StoreOneRouteAfterSessionLoad(0, &OneRoute);
20409 if((NumberOfRoutes < 0) || (NumberOfRoutes > 5000))
20416 if((NextID < 0) || (NextID > 1000000))
20421 for(
int x = 0; x < NumberOfRoutes; x++)
20446 AnsiString(StartPosition));
20447 if(EndPosition == StartPosition)
20453 int TVPos = EndPosition;
20454 int LkPos = EndXLinkPos;
20456 while(TrackIsInARoute(15, TVPos, LkPos))
20483 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
20492 if((NewLkPos == 0) || (NewLkPos == 2))
20512 if(TVPos == StartPosition)
20544 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
20549 if(FirstPair.first > -1)
20552 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20557 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20563 if(SecondPair.first > -1)
20566 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20571 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20577 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(0, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(1, HLoc - 1, VLoc,
20584 if(FirstPair.first > -1)
20587 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20592 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20598 if(SecondPair.first > -1)
20601 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20606 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20612 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(2, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(3, HLoc, VLoc - 1,
20619 if(FirstPair.first > -1)
20622 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20627 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20633 if(SecondPair.first > -1)
20636 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20641 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20647 if(((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(4, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(5, HLoc + 1, VLoc,
20654 if(FirstPair.first > -1)
20657 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20662 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20668 if(SecondPair.first > -1)
20671 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20676 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20682 if(((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(6, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(7, HLoc, VLoc + 1,
20706 "," + AnsiString(DiagonalLinkNumber));
20711 if(FirstPair.first > -1)
20714 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20719 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20725 if(SecondPair.first > -1)
20728 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20733 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20740 if(FirstPair.first > -1)
20743 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20748 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20754 if(SecondPair.first > -1)
20757 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20762 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20769 if(FirstPair.first > -1)
20772 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20777 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20783 if(SecondPair.first > -1)
20786 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20791 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20798 if(FirstPair.first > -1)
20801 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20806 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20812 if(SecondPair.first > -1)
20815 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20820 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))